﻿using System;
using System.Collections.Generic;
using System.Globalization;

namespace CodeCounsel.SharePoint2010.DigiD
{
    abstract class WebResponse
    {
        public ResultCode ResultCode { get { return ParseResultCode(Parameters[Schema.ResultCode]); } }
        protected Dictionary<string, string> Parameters { get; private set; }

        protected WebResponse(Uri uri)
        {
            Parameters = uri.GetQuery();
        }

        protected WebResponse(Dictionary<string, string> parameters)
        {
            Parameters = parameters;
        }

        ResultCode ParseResultCode(string resultCodeText)
        {
            return (ResultCode)Int32.Parse(resultCodeText, NumberStyles.HexNumber);
        }
    }
}
